package state.group.events;

import messages.ByteList;
import state.group.HallCall;

public class HallCallEvent extends BaseEvent {
    
    private HallCall call;
    private byte isRegistration;
    
    public HallCallEvent(byte[] data, int startIndex)
    {
        call = new HallCall(data[startIndex + 1], data[startIndex + 2]);
        isRegistration = data[startIndex + 3];
    }
    
    public HallCallEvent(HallCall call, boolean isRegistration)
    {
        this.call = call;
        this.isRegistration = (byte) (isRegistration ? 1 : 0);
    }
    
    public HallCall getHallCall()
    {
        return call;
    }
    
    public boolean isRegistration()
    {
        return isRegistration == 1;
    }
    
    @Override
    public void appendToByteList(ByteList list)
    {
        super.appendToByteList(list);
        list.addByte(call.getFloor());
        list.addByte(call.getDirection());
        list.addByte(isRegistration);
    }
    
    @Override
    public int getEventByteLength()
    {
        return 4;
    }

    @Override
    public EventType getEventType()
    {
        return EventType.HallCallEvent;
    }

}
